app.controller('ziyezhipai',['$scope','mainService','$location','$http',function($scope,mainService,$location,$http){




    if(mainService.getData()){

        $scope.zgyq=mainService.getData().zgyq;
        $scope.zgcs=mainService.getData().zgcs;

        $scope.slr=mainService.getData().slr;
        $scope.yjya=mainService.getData().yjya;

    }

    $scope.changeState = function (){



                mainService.setData({
                    xq:mainService.getData().xq,
                    incoming:mainService.getData().incoming,
                    slrData:mainService.getData().slrData,
                    slr:$scope.slr,
                    yjya:$scope.yjya,
                    yjyaData:mainService.getData().yjyaData,
                    zgyq:$scope.zgyq,
                    zgcs:$scope.zgcs
                })
                console.log(mainService.getData())

    }

$scope.submit = function () {
    if(getInputs()==false){
        return;
    }
    $http({
        method: "POST",
        url: mainUrl + '/tr/tr-reform-plan!addAndUpdateState4App.action',
        params: {
            'Authorization': token,
            'tcrlSid':mainService.getData().xq.yhSid ,   //应yhSid	隐患sid
            'orgCompany':mainService.getData().xq.orgCompany,   // 对应orgCompany 公司
            'orgDepartment':mainService.getData().xq.orgDepartment,   // 对应orgDepartment
            'orgArea':mainService.getData().xq.orgArea,   // 对应orgArea
            'troDesc':mainService.getData().xq.troDesc,   //应troDesc隐患描述
            'state':mainService.getData().xq.yhState,   // 对应 yhState隐患状态
            'troLevel':mainService.getData().xq.troLevel,   // 对应troLevel
            'troPositiion':mainService.getData().xq.troPositiion,   //应troPositiion
            'troId':mainService.getData().xq.troId,   // 对应troId
            'reformName':mainService.getData().slr.staffName,   // 对应选中整改负责人中文
            'reformId':mainService.getData().slr.identityId,   // 对应选中整改负责人身份证
            'planReformDt': localStorage.getItem('dateInput'),   // 对应表单整改时限日期
            'emeDeal':mainService.getData().yjyaData.planName,   // 对应选中应急预案文本
            'troRequire':$scope.zgyq,   // 对应表单整改要求
            'version':1,   // 默认1
            'delFlag':0,   // 默认0
            'controlMeasures':$scope.zgcs,   // 添加整改(治理)措施字段
       }
    }).then(
        function (data, status, headers, config) {
            console.log(data)
            //$scope.data = data.data.items;

            mui.hideLoading();
            mui.toast('提交成功');
            $location.path('/liuzhuandaichuliyinhuan');
            mainService.reset()
            // document.getElementsByClassName('mui-switch-blue').addEventListener
        }, function (data, status, headers, config) {
            console.log(data)
            console.log(status)
        })

};


}])
